import { ref, reactive } from "vue";
import { ElMessage } from "element-plus";
import { getProjectList } from "../../../api/projectList/index";
import { type ProjectType } from "../../../api/projectList";

export const useData = () => {
  const mainData = ref<ProjectType[]>([]);
  const loadData = async () => {
    try {
      const { rows, msg, total } = await getProjectList();
      if (!rows) {
        return;
      } else {
        ElMessage.success("获取成功");
        mainData.value = rows;
      }
    } catch (e) {
      //TODO handle the exception
      ElMessage.success("业务 获取项目列表失败");
      console.error(e);
    }
  };
  return {
    mainData,
    loadData,
  };
};
